<?php #//AJAX PHP PENNY AUCTION v.1.1

#///////////////////////////////////////////////////////////
#//  COPYRIGHT 2009 Aaron Helmlinger ALL RIGHTS RESERVED  //
#///////////////////////////////////////////////////////////


require('../includes/config.inc.php');
include "loggedin.inc.php"; 





$prefix="../";
#//
$ERR = "";

#//
$query = "SELECT * FROM PHPAUCTIONXL_settings";
$res = @mysql_query($query);
if(!$res) {
	print "Error: $query<BR>".mysql_error();
	exit;
} elseif(mysql_num_rows($res) > 0) {
	$HOME_SETTINGS = mysql_fetch_array($res);
	$SETTINGS=array_merge($SETTINGS,$HOME_SETTINGS);
}
if(file_exists(realpath(phpa_uploaded()."settings.ini"))) {
	$INI_SETTINGS=parse_ini_file(realpath(phpa_uploaded()."settings.ini"));
	$SETTINGS=array_merge($SETTINGS,$INI_SETTINGS);
}

#//
if($_POST['action'] == "update")
{

        
                 
                 



  if($_FILES['logo']['tmp_name']){
	#// Handle logo upload
	$inf = GetImageSize ($_FILES['logo']['tmp_name']);
	if ( $inf[2]<1 || $inf[2]>3 ) {
		print $ERR_602;
		exit;
	}
        if ( filesize($_FILES['logo']['tmp_name']) > $_POST['MAX_FILE_SIZE'] ) 
        {
          print $ERR_603;
          exit;   
        }
	if(!empty($_FILES['logo']['tmp_name']) && $_FILES['logo']['tmp_name'] != "none") {
		//		$TARGET = $image_upload_path.$_FILES['logo']['name'];
		$TARGET = realpath(phpa_uploaded())."/".$_FILES['logo']['name'];
		@move_uploaded_file($_FILES['logo']['tmp_name'],$TARGET);
		chmod($TARGET,0666);
		$LOGOUPLOADED = TRUE;
	}
  }

	#// Handle logo upload
	if(!empty($_FILES['background']['tmp_name']) && $_FILES['background']['tmp_name'] != "none") {
		//		$TARGET = $image_upload_path.$_FILES['background']['name'];
		$TARGET = realpath(phpa_uploaded())."/".$_FILES['background']['name'];
		@move_uploaded_file($_FILES['background']['tmp_name'],$TARGET);
		chmod($TARGET,0666);
		$BACKUPLOADED = TRUE;
	}

	$query = " UPDATE PHPAUCTIONXL_settings SET
				   loginbox=".$_POST['loginbox'].",
				   newsbox=".$_POST['newsbox'].",
				   newstoshow=".$_POST['newstoshow'].",";
	$INI_SETTINGS[loginbox]=$_POST['loginbox'];
	$INI_SETTINGS[newsbox]=$_POST['newsbox'];
	$INI_SETTINGS[newstoshow]=$_POST['newstoshow'];
	if($LOGOUPLOADED) {
		$query .= "logo='".$_FILES['logo']['name']."', ";
		$INI_SETTINGS[logo]=$_FILES['logo']['name'];
	}
	if($BACKUPLOADED) {
		$query .= "background='".$_FILES['background']['name']."', ";
		$INI_SETTINGS[background]=$_FILES['background']['name'];
	}
	$query .= "brepeat='".$_POST['brepeat']."',
					featureditemsnumber=".intval($_POST['featureditemsnumber']).",
					featuredcolumns=".intval($_POST['featuredcolumns']).",
					lastitemsnumber=".intval($_POST['lastitemsnumber']).",
					catfeatureditemsnumber=".intval($_POST['catfeatureditemsnumber']).",
					catthumbnailswidth=".intval($_POST['catthumbnailswidth']).",
					higherbidsnumber=".intval($_POST['higherbidsnumber']).",
					endingsoonnumber=".intval($_POST['endingsoonnumber']).",
					thimbnailswidth=".intval($_POST['thimbnailswidth']).",
					pagewidth=".intval($_POST['pagewidth']).",
					pagewidthtype='".$_POST['pagewidthtype']."',
					alignment='".$_POST['alignment']."';";
          
          	
	$INI_SETTINGS[brepeat]=$_POST['brepeat'];
	$INI_SETTINGS[featureditemsnumber]=intval($_POST['featureditemsnumber']);
	$INI_SETTINGS[featuredcolumns]=intval($_POST['featuredcolumns']);
	$INI_SETTINGS[lastitemsnumber]=intval($_POST['lastitemsnumber']);
	$INI_SETTINGS[catfeatureditemsnumber]=intval($_POST['catfeatureditemsnumber']);
	$INI_SETTINGS[catthumbnailswidth]=intval($_POST['catthumbnailswidth']);
	$INI_SETTINGS[higherbidsnumber]=intval($_POST['higherbidsnumber']);
	$INI_SETTINGS[endingsoonnumber]=intval($_POST['endingsoonnumber']);
	$INI_SETTINGS[thimbnailswidth]=intval($_POST['thimbnailswidth']);
	$INI_SETTINGS[pagewidth]=intval($_POST['pagewidth']);
	$INI_SETTINGS[pagewidthtype]=$_POST['pagewidthtype'];
	$INI_SETTINGS[alignment]=$_POST['alignment'];
	$initxt="";
	foreach($INI_SETTINGS as $k=>$v)
	$initxt.="$k=$v\r\n";
	$fp=fopen(realpath(phpa_uploaded())."/"."settings.ini","w");
	fwrite($fp,$initxt);
	fclose($fp);
	$res_ = @mysql_query($query);
	if(!$res_) {
		print "Error: $query<BR>".mysql_error();
		exit;
	} else {
		$SETTINGS=array_merge($SETTINGS,$INI_SETTINGS);
		$ERR = $MSG_5019;
	}
}


$query_settings = "select * from PHPAUCTIONXL_version_1_3 where id='1'";
                             $query_settings2 =  mysql_query ($query_settings);
                                $closed_auctions2 = mysql_result($query_settings2,0,"closed_auctions");
            
        if ( empty($closed_auctions2)){    
              $query2="UPDATE PHPAUCTIONXL_version_1_3 SET closed_auctions='6' WHERE id='1'";
       
mysql_query($query2); 
          }         
          
          $query_settings = "select * from PHPAUCTIONXL_version_1_3 where id='1'";
                             $query_settings2 =  mysql_query ($query_settings);
                                $closed_auctions2 = mysql_result($query_settings2,0,"closed_auctions");
           
                                ?>
                                
<img src="<?=phpa_uploaded().$SETTINGS['logo']?>">


